package com.demo.applicationlistener;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.ServletRequestHandledEvent;

//注册监听器
@Component
public class WebApplicationStartedEventListener implements ApplicationListener<ApplicationEvent> {

	// 日志记录
	private Logger log = Logger.getLogger(WebApplicationStartedEventListener.class);

	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		if (event instanceof ServletRequestHandledEvent) {
			// ServletRequestHandledEvent web请求监听
//			log.info("web请求监听");
//			log.info("web请求监听:" + event.toString());
		}

	}

}